//
//  ViewController.m
//  ios11-1
//
//  Created by mac on 15-11-2.
//  Copyright (c) 2015年 Lee. All rights reserved.
//

#import "ViewController.h"
<<<<<<< HEAD
#import "QuartzCore/QuartzCore.h"
#import "TestViewController.h"
#import "IOSViewController.h"
@interface ViewController ()

=======
#import <QuartzCore/QuartzCore.h>
<<<<<<< HEAD
#import "IOStestViewController.h"
=======
>>>>>>> c7f3369b981104113bc0b4ce39f14fedabb0eb08

@interface ViewController ()
>>>>>>> bb81f23902fbad5a6e7abe6579fede1a13dd9221
{
    UILabel * l;
}
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
<<<<<<< HEAD
    
    self.title = @"我的标题栏";
    
    
    
    self.view.backgroundColor = [UIColor brownColor];
=======
<<<<<<< HEAD
    self.title = @"我的标题栏";
    
=======
<<<<<<< HEAD
>>>>>>> c7f3369b981104113bc0b4ce39f14fedabb0eb08
    self.view.backgroundColor = [UIColor blueColor];
>>>>>>> bb81f23902fbad5a6e7abe6579fede1a13dd9221
    //UILabel * l = [[UILabel alloc] initWithFrame:CGRectMake(50, 200, 100, 44)];
    l = [UILabel new];
    l.text = @"你好，世界";
    [l sizeToFit];
<<<<<<< HEAD
    l.center = CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.height/2.0);
    l.textColor = [UIColor blackColor];
    [self.view addSubview:l];
    
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [self.view bringSubviewToFront:btn];
    btn.frame = CGRectMake(100, 100, 44, 44);
    [btn setTitle:@"按钮" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(onClick2:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
    
/*    UIView * view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    view.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:view];
    
    for (int i = 0; i<5; i++) {
        UIView *v = [[UIView alloc] initWithFrame:CGRectMake(i*20+i*50, 100 , 50,i*20 + i*50)];
        v.backgroundColor = [UIColor yellowColor];
        
        v.layer.cornerRadius = 50/2.0;
        v.clipsToBounds = YES;
        
        [self.view addSubview:v];
    }
  
    UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(20, 200, 200, 200)];
    line1.layer.borderWidth = 2;
    [self.view addSubview:line1];
    UIView * yuan = [[UIView alloc] initWithFrame:CGRectMake(100, 0, 200, 200)];
    yuan.layer.cornerRadius = 100;
    yuan.layer.borderWidth = 2;
    [line1 addSubview:yuan];

    UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(0,99, 200, 2)];
    line2.backgroundColor = [UIColor blackColor];
    [line1 addSubview:line2];
    
    UIView * line3 = [[UIView alloc]initWithFrame:CGRectMake(99, 0, 2, 200)];
    line3.backgroundColor = [UIColor blackColor];
    [line1 addSubview:line3];
    
    for (int i = 0; i<5; i++) {
        CGFloat stepper = 20;
        UIView  *view = [[UIView alloc]initWithFrame:CGRectMake(20+i*stepper, 60+i*stepper, 200-2*i*stepper, 200-2*i*stepper)];
        view.backgroundColor = [UIColor whiteColor];
        view.layer.borderWidth = 1;
        [self.view addSubview:view];
    }
*/    
}

- (void)onClick:(id)sender{
    
    UIView * line = [[UIView alloc] initWithFrame:CGRectMake(0, 200, 0, 3)];
    line.backgroundColor = [UIColor blackColor];
    [self.view addSubview:line];
    
    UIView * line2 = [[UIView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2.0, 0, 6, 0)];
    line2.backgroundColor = [UIColor blackColor];
    [self.view addSubview:line2];
    
        [UIView animateWithDuration:0.6 animations:^{//匿名函数
            line.frame = CGRectMake(0, 200, self.view.frame.size.width, 3);
        } completion:^(BOOL finish){//回调函数
            [UIView animateWithDuration:0.6 animations:^{
                line2.frame = CGRectMake(self.view.frame.size.width/2.0, 0, 3, self.view.frame.size.height);
                [UIView animateWithDuration:0.6 animations:^{
                    line.frame = CGRectMake(self.view.frame.size.width,200,0,6);
                    line2.frame = CGRectMake(self.view.frame.size.width/2.0, 0, 6, self.view.frame.size.height);
                } completion:^(BOOL finish){
                    [UIView animateWithDuration:0.6 animations:^{
                        line2.frame = CGRectMake(self.view.frame.size.width/2.0, self.view.frame.size.height, 6, 0);
                    }];
                }];
            }];
        }];
    
    
}

//- (void)onClick2:(id)sender{
//    TestViewController * con = [[TestViewController alloc] init];
//    [self.navigationController pushViewController:con animated:YES];
//}

- (void)onClick2:(id)sender{
    IOSViewController * con = [[IOSViewController alloc] init];
    [self.navigationController pushViewController:con animated:YES];
}




- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    //[self.view bringSubviewToFront:l];
    [UIView animateWithDuration:2 animations:^{
        l.center = CGPointMake(self.view.frame.size.width/5,44);
    }];

=======
    l.center = CGPointMake(self.view.frame.size.width / 2.0, self.view.frame.size.height / 2.0);
    l.textColor = [UIColor blackColor];
    [self.view addSubview:l];
    

//    UIView * view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
//    view.backgroundColor = [UIColor yellowColor];
//    [self.view addSubview:view];
  
//    for (int i = 0; i<5; i++) {
//        UIView *v = [[UIView alloc] initWithFrame:CGRectMake(i*20 + i*80, 100 , 5, 200)];
//        v.backgroundColor = [UIColor yellowColor];
//        
////        v.layer.cornerRadius = 50/2.0;
////        v.clipsToBounds = YES;
//        
//        [self.view addSubview:v];
//    }
<<<<<<< HEAD
=======
=======
    self.view.backgroundColor = [UIColor brownColor];
    UILabel * l = [[UILabel alloc] initWithFrame:CGRectMake(50, 200, 100, 44)];
   // l.text = @"你好，世界";
   // l.textColor = [UIColor blackColor];
    [self.view addSubview:l];
    
//    UIView * view = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
//    view.backgroundColor = [UIColor yellowColor];
//    [self.view addSubview:view];
    
    for (int i = 0; i<5; i++) {
        UIView *v = [[UIView alloc] initWithFrame:CGRectMake(i*20 + i*50, 100 , 50, 200)];
        v.backgroundColor = [UIColor yellowColor];
        
//        v.layer.cornerRadius = 50/2.0;
//        v.clipsToBounds = YES;
        
        [self.view addSubview:v];
    }
>>>>>>> b4031a5586299eed34e3cec182a9ea07a96bd236
>>>>>>> c7f3369b981104113bc0b4ce39f14fedabb0eb08
    
   /* UIView * linel = [[UIView alloc] initWithFrame:CGRectMake(200, 50, 5, 300)];
    linel.backgroundColor = [UIColor blackColor ];
    [self.view addSubview:linel];   */
    
<<<<<<< HEAD
=======
<<<<<<< HEAD
>>>>>>> c7f3369b981104113bc0b4ce39f14fedabb0eb08
//    for (int i =0; i<3;i++ ) {
//        UIView * linel = [[UIView alloc] initWithFrame:CGRectMake(i*20 + i*80, 0, 5, 150)];
//        linel.backgroundColor = [UIColor blackColor ];
//        [self.view addSubview:linel];
//    }
//    for (int i=0; i<3; i++) {
//        UIView * linel1 = [[UIView alloc] initWithFrame:CGRectMake(5, i*50 + i*20, 200, 10)];
//        linel1.backgroundColor = [UIColor blackColor ];
//        [self.view addSubview:linel1];
//    }
   
    /*
    
    [super viewDidLoad];
	 //Do any additional setup after loading the view, typically from a nib.
    UIView * block = [[UIView alloc] initWithFrame:CGRectMake(100, 300, 100, 100)];
    
    self.view.backgroundColor = [UIColor redColor];
    //UILabel * l = [[UILabel alloc] initWithFrame:CGRectMake(50, 200, 100, 44)];
    //l.text = @"你好，世界";
    //l.textColor = [UIColor blackColor];
    //[self.view addSubview:l];
    
        for (int i=0; i<5; i++) {
            CGFloat stepper = 20;
            UIView * view = [[UIView alloc] initWithFrame:CGRectMake(20+ i*stepper, 60 +i *stepper, 200 - 2*i*stepper, 200-2*i*stepper)];
            view.backgroundColor = [UIColor whiteColor];
            view.layer.borderWidth = 1;
            [self.view addSubview:view];
        }
    
    UIView * v = [[UIView alloc] initWithFrame:CGRectMake(20, 200, 200, 200)];
    v.layer.borderWidth = 2;
    [self.view addSubview:v];
    
    UIView * line2 = [[UIView alloc] initWithFrame:CGRectMake(0, 99, 200, 2)];
    line2.backgroundColor = [UIColor blackColor];
    [v addSubview:line2];
    
    UIView * line3 = [[UIView alloc] initWithFrame:CGRectMake(99, 0, 2, 200)];
    line3.backgroundColor = [UIColor blackColor];
    [v addSubview:line3];
    
    UIView * yuan = [[UIView alloc] initWithFrame:CGRectMake(100, 0, 200, 200)];
    yuan.layer.cornerRadius = 100;
    yuan.layer.borderWidth = 2;
    [v addSubview:yuan];
    */
    
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [UIView animateWithDuration:1 animations:^{
        l.center = CGPointMake(self.view.frame.size.width / 2.0, self.view.frame.size.height / 2.0);
    }];
    
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect ];
<<<<<<< HEAD
    btn.frame = CGRectMake(50, 50, 100, 44);
    [btn setTitle:@"按钮" forState: UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventTouchUpInside];
  
    [self.view addSubview:btn];
 
}

- (void)onClick:(id)sender
{
    IOStestViewController *con = [IOStestViewController new];
    [self.navigationController pushViewController:con animated:YES];
}

- (void)onClick1:(id)sender
{
    
    [UIView animateWithDuration:1 animations:^{
        for (int i=0; i<3; i++) {
            UIView * line = [[UIView alloc] initWithFrame:CGRectMake(0, 200, 0,6)];
            line.backgroundColor = [UIColor blackColor];
            [self.view addSubview:line];
            line.frame = CGRectMake(i*20 + i*80, 0, 5, 150);
        }
    } completion:^(BOOL finish){
        for (int i=0; i<3; i++) {
            UIView * line2 = [[UIView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2.0, 0, 6, 0)];
            line2.backgroundColor = [UIColor blackColor];
            [self.view addSubview:line2];
            [UIView animateWithDuration:0.6 animations:^{
                //竖线
                line2.frame = CGRectMake(5, i*50 + i*20, 200, 10);
            }];
        }
    }];
     
}

- (void)onClick2:(id)sender
{
    //设置横线的位置，大小，颜色
    UIView * line = [[UIView alloc] initWithFrame:CGRectMake(0, 200, 0,6)];
    line.backgroundColor = [UIColor blackColor];
    [self.view addSubview:line];
    //设置竖线的位置，大小，颜色
    UIView * line2 = [[UIView alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2.0, 0, 6, 0)];
    line2.backgroundColor = [UIColor blackColor];
    [self.view addSubview:line2];
    //设置动画
    [UIView animateWithDuration:0.6 animations:^{
        //横线
        line.frame = CGRectMake(0, 200, self.view.frame.size.width,6 );
    }completion:^(BOOL finish){
        //动画里面在套入动画
        [UIView animateWithDuration:0.6 animations:^{
            [UIView animateWithDuration:0.6 animations:^{
                //横线出来慢慢消失，竖线出来
                line.frame = CGRectMake(self.view.frame.size.width, 200, 0,6 );
                //竖线
                line2.frame = CGRectMake(self.view.frame.size.width/2.0, 0, 6, self.view.frame.size.height);
        } completion:^(BOOL finish){
            //竖线消失
            [UIView animateWithDuration:0.6 animations:^{
                line2.frame = CGRectMake(self.view.frame.size.width/2.0, self.view.frame.size.height, 6,0 );
                }];
            }];
        }];
    }]; 
=======
    btn.frame = CGRectMake(100, 100, 200, 44);
    [btn setTitle:@"按钮" forState: UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(onClick1:) forControlEvents:UIControlEventTouchUpInside];
  
    [self.view addSubview:btn];
 
=======
    for (int i =0; i<3;i++ ) {
        UIView * linel = [[UIView alloc] initWithFrame:CGRectMake(i*20 + i*80, 0, 5, 150)];
        linel.backgroundColor = [UIColor blackColor ];
        [self.view addSubview:linel];
    }
    for (int i=0; i<3; i++) {
        UIView * linel1 = [[UIView alloc] initWithFrame:CGRectMake(5, i*50 + i*20, 200, 10)];
        linel1.backgroundColor = [UIColor blackColor ];
        [self.view addSubview:linel1];
    }
    
    
    
>>>>>>> b4031a5586299eed34e3cec182a9ea07a96bd236
}

- (void)onClick:(id)sender
{
    [UIView animateWithDuration:1.6 animations:^{
        l.center = CGPointMake(self.view.frame.size.width/2.0, 44);
    }];
}

- (void)onClick1:(id)sender
{
    UIView * line = [[UIView alloc] initWithFrame:CGRectMake(0, 99, 200,5)];
    line.backgroundColor = [UIColor blackColor];
    line.layer.borderWidth = 2;
    [self.view addSubview:line];
    [UIView animateWithDuration:1.6 animations:^{
        line.center = CGPointMake(self.view.frame.size.width/2.0, 44);
        l.center = CGPointMake(self.view.frame.size.width/2.0, 44);
    }];
    
    
>>>>>>> c7f3369b981104113bc0b4ce39f14fedabb0eb08
    
>>>>>>> bb81f23902fbad5a6e7abe6579fede1a13dd9221
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
